package com.techb.controller.authentication;

import java.util.ArrayList;

import javax.servlet.ServletContext;

import org.apache.struts2.ServletActionContext;
import com.techb.table.UserDTO;
import com.techb.model.UserDAO;

import com.opensymphony.xwork2.ActionSupport;


public class CheckValidity extends ActionSupport{

	private static final long serialVersionUID = -3308886200897622656L;
	UserDTO user=new UserDTO();
	UserDAO userDao=new UserDAO();
	private String userId;
	private String password;
	private String lotteryStatus;
	
	
	public String execute()
	{

		
		/*
		String submittedAuthKey="";
		String savedAuthKey="";
		String localIp=ServletActionContext.getRequest().getHeader("X-Forwarded-For")==null?"":ServletActionContext.getRequest().getHeader("X-Forwarded-For");
		String via=ServletActionContext.getRequest().getHeader("Via")==null?"":ServletActionContext.getRequest().getHeader("Via");
		String realIp=ServletActionContext.getRequest().getRemoteAddr()==null?"":ServletActionContext.getRequest().getRemoteAddr();
		submittedAuthKey=localIp+via+realIp;
		*/
		
		this.user=userDao.validateLogin(userId, password);
		if(user==null)
		{
			addActionMessage("Invalid Userid or Password.");
			return INPUT;
		}
		else
		{
			return "mian_menu";
		}
	}

	public ServletContext getServletContext()
	{
		return ServletActionContext.getServletContext();
	}
	public UserDTO getUser() {
		return user;
	}
	public void setUser(UserDTO user) {
		this.user = user;
	}


	public String getUserId() {
		return userId;
	}


	public void setUserId(String userId) {
		this.userId = userId;
	}


	public String getPassword() {
		return password;
	}


	public void setPassword(String password) {
		this.password = password;
	}

	public String getLotteryStatus() {
		return lotteryStatus;
	}

	public void setLotteryStatus(String lotteryStatus) {
		this.lotteryStatus = lotteryStatus;
	}
	
}
